home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickTime / Programming Stuff / Documentation / develop articles / develop Issue 24 / Printing Compressed Images / JPEG Print / PrintJPEG.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-03  |  2.9 KB  |  113 lines  |  [TEXT/MPCC]

  1. #ifndef __PRINTJPEG__
  2. #define __PRINTJPEG__
  3.  
  4. #include <ImageCompression.h>
  5.  
  6. struct JPEGImage {
  7.     Handle    theData;                        /*the Data Handle*/
  8.     Rect    theBounds;                        /* the Bounds of the Image */    
  9.     ImageDescriptionHandle theDesc;            /* an ImageDescriptionHandle */
  10. };
  11. typedef struct JPEGImage JPEGImage;
  12.  
  13. // macro for determining if the port is a color port.
  14. #define ISCOLORPORT(gPort) (((gPort)->portBits.rowBytes & 0x8000) != 0)
  15.  
  16.  
  17. /*
  18.     JPEG Marker code definitions.    
  19. */
  20. #define    MARKER_PREFIX    0xff
  21. #define    MARKER_SOI        0xd8        /* start of image */
  22. #define    MARKER_SOF        0xc0        /* start of frame codes */
  23. #define    MARKER_DHT        0xc4        /* define Huffman table */
  24. #define    MARKER_EOI        0xd9        /* end of image */
  25. #define    MARKER_SOS        0xda        /* start of scan */
  26. #define    MARKER_DQT        0xdb        /* define quantization tables */
  27. #define    MARKER_DNL        0xdc        /* define quantization tables */
  28. #define    MARKER_DRI        0xdd        /* define Huffman table */
  29. #define    MARKER_COM        0xfe        /* comment */
  30. #define MARKER_APP0        0xe0        
  31.  
  32.  
  33. //=====================================================================================
  34. // Public interface function prototypes
  35. //=====================================================================================
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. static OSErr ReadJPEGData(FSSpec *theSpec, Handle *theData);
  42.  
  43. static OSErr SetJPEGBounds(JPEGImage * theJPEGImage);
  44.  
  45. static OSErr MakeJPEGImageDescription(JPEGImage *theJPEGImage);
  46.  
  47. static char *
  48. MarkerDetect(char *data,short *width,short *height,long *hRes,long *vRes,short *depth);
  49.  
  50. static void SwallowQuantTable(char *data);
  51.  
  52. static void SwallowHuffTable(char *data);
  53.  
  54. static OSErr DrawJPEGImage(JPEGImage theJPEGImage, Boolean isColorPort);
  55.  
  56. SInt16 main(void);
  57. static OSErr initMacintosh(void);
  58. static OSErr SetupMenus(void);
  59. static SInt16 handleEvent(void);
  60. static OSErr Print(JPEGImage theJPEGImage, THPrint aPrintRecordHandle);
  61. static void DoKeyDown(EventRecord *);
  62. static void doCommand(SInt16,SInt16);
  63. static void showAboutMeDialog(void) ;
  64. static void DoTheOpenCommand(void);
  65.  
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69.  
  70. /*
  71.  * Resource ID constants.
  72. */
  73. #define kAppleMenuID     128   /* This identifies the apple menu*/
  74. #define kFileMenuID        129
  75. #define kEditMenuID        130
  76.  
  77. // Apple Menu Item Numbers 
  78. #define kAboutMeCommand  1 
  79.  
  80. // File Menu Item Numbers 
  81. #define kOpenCommand        1
  82. #define kSaveCommand        2
  83. // separator line            3
  84. #define kPageSetupCommand    4
  85. #define kPrintCommand        5
  86. // separator line            6
  87. #define kQuitCommand        7
  88.  
  89. /*
  90.  * Support for the About Dialog
  91. */
  92. #define    kAboutMeDLOG        128
  93. #define    kOKButton            1
  94.  
  95. // alert dialog ID to report problems to users.
  96. #define kGenericError         128
  97.  
  98. // define for flags value for calls to StdPix bottleneck.
  99. #define kCallOldBits        (1 << 0)  
  100. #define kCallStdBits        (1 << 1)  
  101.  
  102. #define MIN(x,y)  ( x  >  y  ) ?  y  :  x 
  103.  
  104. #define kSleepTime  5
  105. #define kInsetBits     10
  106.  
  107. // Application Specific Errors
  108. #define kAppError             4017
  109. #define iNotJPEGData         4019
  110. #define kCouldntLoadMenu     4020
  111.  
  112. #endif
  113.